﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using FreeLancer.HRB.Domains;
using FreeLancer.HRB.DataAccess;

#endregion

namespace FreeLancer.HRB.DataAccess.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="PostsProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class PostsProviderBaseCore : EntityProviderBase<FreeLancer.HRB.Domains.Posts, FreeLancer.HRB.Domains.PostsKey>
	{		
		#region Get from Many To Many Relationship Functions
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, FreeLancer.HRB.Domains.PostsKey key)
		{
			return Delete(transactionManager, key.PostId);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="_postId">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.Guid _postId)
		{
			return Delete(null, _postId);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_postId">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.Guid _postId);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override FreeLancer.HRB.Domains.Posts Get(TransactionManager transactionManager, FreeLancer.HRB.Domains.PostsKey key, int start, int pageLength)
		{
			return GetByPostId(transactionManager, key.PostId, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_hrbPosts index.
		/// </summary>
		/// <param name="_postId"></param>
		/// <returns>Returns an instance of the <see cref="FreeLancer.HRB.Domains.Posts"/> class.</returns>
		public FreeLancer.HRB.Domains.Posts GetByPostId(System.Guid _postId)
		{
			int count = -1;
			return GetByPostId(null,_postId, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_hrbPosts index.
		/// </summary>
		/// <param name="_postId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="FreeLancer.HRB.Domains.Posts"/> class.</returns>
		public FreeLancer.HRB.Domains.Posts GetByPostId(System.Guid _postId, int start, int pageLength)
		{
			int count = -1;
			return GetByPostId(null, _postId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_hrbPosts index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_postId"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="FreeLancer.HRB.Domains.Posts"/> class.</returns>
		public FreeLancer.HRB.Domains.Posts GetByPostId(TransactionManager transactionManager, System.Guid _postId)
		{
			int count = -1;
			return GetByPostId(transactionManager, _postId, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_hrbPosts index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_postId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="FreeLancer.HRB.Domains.Posts"/> class.</returns>
		public FreeLancer.HRB.Domains.Posts GetByPostId(TransactionManager transactionManager, System.Guid _postId, int start, int pageLength)
		{
			int count = -1;
			return GetByPostId(transactionManager, _postId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_hrbPosts index.
		/// </summary>
		/// <param name="_postId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="FreeLancer.HRB.Domains.Posts"/> class.</returns>
		public FreeLancer.HRB.Domains.Posts GetByPostId(System.Guid _postId, int start, int pageLength, out int count)
		{
			return GetByPostId(null, _postId, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_hrbPosts index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_postId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="FreeLancer.HRB.Domains.Posts"/> class.</returns>
		public abstract FreeLancer.HRB.Domains.Posts GetByPostId(TransactionManager transactionManager, System.Guid _postId, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#region _hrbPosts_GetRelatedPost 
		
		/// <summary>
		///	This method wrap the '_hrbPosts_GetRelatedPost' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="isPublished"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="headerImageFolder"> A <c>System.String</c> instance.</param>
		/// <param name="numberOfPosts"> A <c>System.Int32?</c> instance.</param>
		/// <param name="postDateCreated"> A <c>System.DateTime?</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetRelatedPost(System.String categoryId, System.Int32? languageId, System.Boolean? isPublished, System.String headerImageFolder, System.Int32? numberOfPosts, System.DateTime? postDateCreated)
		{
			return GetRelatedPost(null, 0, int.MaxValue , categoryId, languageId, isPublished, headerImageFolder, numberOfPosts, postDateCreated);
		}
		
		/// <summary>
		///	This method wrap the '_hrbPosts_GetRelatedPost' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="isPublished"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="headerImageFolder"> A <c>System.String</c> instance.</param>
		/// <param name="numberOfPosts"> A <c>System.Int32?</c> instance.</param>
		/// <param name="postDateCreated"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetRelatedPost(int start, int pageLength, System.String categoryId, System.Int32? languageId, System.Boolean? isPublished, System.String headerImageFolder, System.Int32? numberOfPosts, System.DateTime? postDateCreated)
		{
			return GetRelatedPost(null, start, pageLength , categoryId, languageId, isPublished, headerImageFolder, numberOfPosts, postDateCreated);
		}
				
		/// <summary>
		///	This method wrap the '_hrbPosts_GetRelatedPost' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="isPublished"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="headerImageFolder"> A <c>System.String</c> instance.</param>
		/// <param name="numberOfPosts"> A <c>System.Int32?</c> instance.</param>
		/// <param name="postDateCreated"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetRelatedPost(TransactionManager transactionManager, System.String categoryId, System.Int32? languageId, System.Boolean? isPublished, System.String headerImageFolder, System.Int32? numberOfPosts, System.DateTime? postDateCreated)
		{
			return GetRelatedPost(transactionManager, 0, int.MaxValue , categoryId, languageId, isPublished, headerImageFolder, numberOfPosts, postDateCreated);
		}
		
		/// <summary>
		///	This method wrap the '_hrbPosts_GetRelatedPost' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="isPublished"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="headerImageFolder"> A <c>System.String</c> instance.</param>
		/// <param name="numberOfPosts"> A <c>System.Int32?</c> instance.</param>
		/// <param name="postDateCreated"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public abstract DataSet GetRelatedPost(TransactionManager transactionManager, int start, int pageLength , System.String categoryId, System.Int32? languageId, System.Boolean? isPublished, System.String headerImageFolder, System.Int32? numberOfPosts, System.DateTime? postDateCreated);
		
		#endregion
		
		#region _hrbPosts_GetPostByCategoryIdLanguageIdFE 
		
		/// <summary>
		///	This method wrap the '_hrbPosts_GetPostByCategoryIdLanguageIdFE' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="isPublished"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="headerImageFolder"> A <c>System.String</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetPostByCategoryIdLanguageIdFE(System.String categoryId, System.Int32? languageId, System.Boolean? isPublished, System.String headerImageFolder)
		{
			return GetPostByCategoryIdLanguageIdFE(null, 0, int.MaxValue , categoryId, languageId, isPublished, headerImageFolder);
		}
		
		/// <summary>
		///	This method wrap the '_hrbPosts_GetPostByCategoryIdLanguageIdFE' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="isPublished"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="headerImageFolder"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetPostByCategoryIdLanguageIdFE(int start, int pageLength, System.String categoryId, System.Int32? languageId, System.Boolean? isPublished, System.String headerImageFolder)
		{
			return GetPostByCategoryIdLanguageIdFE(null, start, pageLength , categoryId, languageId, isPublished, headerImageFolder);
		}
				
		/// <summary>
		///	This method wrap the '_hrbPosts_GetPostByCategoryIdLanguageIdFE' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="isPublished"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="headerImageFolder"> A <c>System.String</c> instance.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetPostByCategoryIdLanguageIdFE(TransactionManager transactionManager, System.String categoryId, System.Int32? languageId, System.Boolean? isPublished, System.String headerImageFolder)
		{
			return GetPostByCategoryIdLanguageIdFE(transactionManager, 0, int.MaxValue , categoryId, languageId, isPublished, headerImageFolder);
		}
		
		/// <summary>
		///	This method wrap the '_hrbPosts_GetPostByCategoryIdLanguageIdFE' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="isPublished"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="headerImageFolder"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public abstract DataSet GetPostByCategoryIdLanguageIdFE(TransactionManager transactionManager, int start, int pageLength , System.String categoryId, System.Int32? languageId, System.Boolean? isPublished, System.String headerImageFolder);
		
		#endregion
		
		#region _hrbPosts_GetPostByDateCreated 
		
		/// <summary>
		///	This method wrap the '_hrbPosts_GetPostByDateCreated' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="isPublished"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="headerImageFolder"> A <c>System.String</c> instance.</param>
		/// <param name="dateCreated"> A <c>System.DateTime?</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetPostByDateCreated(System.String categoryId, System.Int32? languageId, System.Boolean? isPublished, System.String headerImageFolder, System.DateTime? dateCreated)
		{
			return GetPostByDateCreated(null, 0, int.MaxValue , categoryId, languageId, isPublished, headerImageFolder, dateCreated);
		}
		
		/// <summary>
		///	This method wrap the '_hrbPosts_GetPostByDateCreated' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="isPublished"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="headerImageFolder"> A <c>System.String</c> instance.</param>
		/// <param name="dateCreated"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetPostByDateCreated(int start, int pageLength, System.String categoryId, System.Int32? languageId, System.Boolean? isPublished, System.String headerImageFolder, System.DateTime? dateCreated)
		{
			return GetPostByDateCreated(null, start, pageLength , categoryId, languageId, isPublished, headerImageFolder, dateCreated);
		}
				
		/// <summary>
		///	This method wrap the '_hrbPosts_GetPostByDateCreated' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="isPublished"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="headerImageFolder"> A <c>System.String</c> instance.</param>
		/// <param name="dateCreated"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetPostByDateCreated(TransactionManager transactionManager, System.String categoryId, System.Int32? languageId, System.Boolean? isPublished, System.String headerImageFolder, System.DateTime? dateCreated)
		{
			return GetPostByDateCreated(transactionManager, 0, int.MaxValue , categoryId, languageId, isPublished, headerImageFolder, dateCreated);
		}
		
		/// <summary>
		///	This method wrap the '_hrbPosts_GetPostByDateCreated' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="isPublished"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="headerImageFolder"> A <c>System.String</c> instance.</param>
		/// <param name="dateCreated"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public abstract DataSet GetPostByDateCreated(TransactionManager transactionManager, int start, int pageLength , System.String categoryId, System.Int32? languageId, System.Boolean? isPublished, System.String headerImageFolder, System.DateTime? dateCreated);
		
		#endregion
		
		#region _hrbPosts_GetPostByCategoryIdLanguageIdBE 
		
		/// <summary>
		///	This method wrap the '_hrbPosts_GetPostByCategoryIdLanguageIdBE' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="TList&lt;Posts&gt;"/> instance.</returns>
		public TList<Posts> GetPostByCategoryIdLanguageIdBE(System.String categoryId, System.Int32? languageId)
		{
			return GetPostByCategoryIdLanguageIdBE(null, 0, int.MaxValue , categoryId, languageId);
		}
		
		/// <summary>
		///	This method wrap the '_hrbPosts_GetPostByCategoryIdLanguageIdBE' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="TList&lt;Posts&gt;"/> instance.</returns>
		public TList<Posts> GetPostByCategoryIdLanguageIdBE(int start, int pageLength, System.String categoryId, System.Int32? languageId)
		{
			return GetPostByCategoryIdLanguageIdBE(null, start, pageLength , categoryId, languageId);
		}
				
		/// <summary>
		///	This method wrap the '_hrbPosts_GetPostByCategoryIdLanguageIdBE' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="TList&lt;Posts&gt;"/> instance.</returns>
		public TList<Posts> GetPostByCategoryIdLanguageIdBE(TransactionManager transactionManager, System.String categoryId, System.Int32? languageId)
		{
			return GetPostByCategoryIdLanguageIdBE(transactionManager, 0, int.MaxValue , categoryId, languageId);
		}
		
		/// <summary>
		///	This method wrap the '_hrbPosts_GetPostByCategoryIdLanguageIdBE' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="TList&lt;Posts&gt;"/> instance.</returns>
		public abstract TList<Posts> GetPostByCategoryIdLanguageIdBE(TransactionManager transactionManager, int start, int pageLength , System.String categoryId, System.Int32? languageId);
		
		#endregion
		
		#region _hrbPosts_GetAllSimplePosts 
		
		/// <summary>
		///	This method wrap the '_hrbPosts_GetAllSimplePosts' stored procedure. 
		/// </summary>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetAllSimplePosts()
		{
			return GetAllSimplePosts(null, 0, int.MaxValue );
		}
		
		/// <summary>
		///	This method wrap the '_hrbPosts_GetAllSimplePosts' stored procedure. 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetAllSimplePosts(int start, int pageLength)
		{
			return GetAllSimplePosts(null, start, pageLength );
		}
				
		/// <summary>
		///	This method wrap the '_hrbPosts_GetAllSimplePosts' stored procedure. 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetAllSimplePosts(TransactionManager transactionManager)
		{
			return GetAllSimplePosts(transactionManager, 0, int.MaxValue );
		}
		
		/// <summary>
		///	This method wrap the '_hrbPosts_GetAllSimplePosts' stored procedure. 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public abstract DataSet GetAllSimplePosts(TransactionManager transactionManager, int start, int pageLength );
		
		#endregion
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a TList&lt;Posts&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="TList&lt;Posts&gt;"/></returns>
		public static TList<Posts> Fill(IDataReader reader, TList<Posts> rows, int start, int pageLength)
		{
			NetTiersProvider currentProvider = DataRepository.Provider;
            bool useEntityFactory = currentProvider.UseEntityFactory;
            bool enableEntityTracking = currentProvider.EnableEntityTracking;
            LoadPolicy currentLoadPolicy = currentProvider.CurrentLoadPolicy;
			Type entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;
			
			// advance to the starting row
			for (int i = 0; i < start; i++)
			{
				if (!reader.Read())
				return rows; // not enough rows, just return
			}
			for (int i = 0; i < pageLength; i++)
			{
				if (!reader.Read())
					break; // we are done
					
				string key = null;
				
				FreeLancer.HRB.Domains.Posts c = null;
				if (useEntityFactory)
				{
					key = new System.Text.StringBuilder("Posts")
					.Append("|").Append((System.Guid)reader[((int)PostsColumn.PostId - 1)]).ToString();
					c = EntityManager.LocateOrCreate<Posts>(
					key.ToString(), // EntityTrackingKey
					"Posts",  //Creational Type
					entityCreationFactoryType,  //Factory used to create entity
					enableEntityTracking); // Track this entity?
				}
				else
				{
					c = new FreeLancer.HRB.Domains.Posts();
				}
				
				if (!enableEntityTracking ||
					c.EntityState == EntityState.Added ||
					(enableEntityTracking &&
					
						(
							(currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
							(currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
						)
					))
				{
					c.SuppressEntityEvents = true;
					c.PostId = (System.Guid)reader[((int)PostsColumn.PostId - 1)];
					c.OriginalPostId = c.PostId;
					c.Title = (reader.IsDBNull(((int)PostsColumn.Title - 1)))?null:(System.String)reader[((int)PostsColumn.Title - 1)];
					c.ImagePath = (reader.IsDBNull(((int)PostsColumn.ImagePath - 1)))?null:(System.String)reader[((int)PostsColumn.ImagePath - 1)];
					c.Description = (reader.IsDBNull(((int)PostsColumn.Description - 1)))?null:(System.String)reader[((int)PostsColumn.Description - 1)];
					c.PostContent = (reader.IsDBNull(((int)PostsColumn.PostContent - 1)))?null:(System.String)reader[((int)PostsColumn.PostContent - 1)];
					c.DateCreated = (reader.IsDBNull(((int)PostsColumn.DateCreated - 1)))?null:(System.DateTime?)reader[((int)PostsColumn.DateCreated - 1)];
					c.DateModified = (reader.IsDBNull(((int)PostsColumn.DateModified - 1)))?null:(System.DateTime?)reader[((int)PostsColumn.DateModified - 1)];
					c.Author = (reader.IsDBNull(((int)PostsColumn.Author - 1)))?null:(System.String)reader[((int)PostsColumn.Author - 1)];
					c.IsPublished = (System.Boolean)reader[((int)PostsColumn.IsPublished - 1)];
					c.Slug = (reader.IsDBNull(((int)PostsColumn.Slug - 1)))?null:(System.String)reader[((int)PostsColumn.Slug - 1)];
					c.Phone = (reader.IsDBNull(((int)PostsColumn.Phone - 1)))?null:(System.String)reader[((int)PostsColumn.Phone - 1)];
					c.Email = (reader.IsDBNull(((int)PostsColumn.Email - 1)))?null:(System.String)reader[((int)PostsColumn.Email - 1)];
					c.Address = (reader.IsDBNull(((int)PostsColumn.Address - 1)))?null:(System.String)reader[((int)PostsColumn.Address - 1)];
					c.IsCommentAllowed = (reader.IsDBNull(((int)PostsColumn.IsCommentAllowed - 1)))?null:(System.Boolean?)reader[((int)PostsColumn.IsCommentAllowed - 1)];
					c.AttachedPath = (reader.IsDBNull(((int)PostsColumn.AttachedPath - 1)))?null:(System.String)reader[((int)PostsColumn.AttachedPath - 1)];
					c.EntityTrackingKey = key;
					c.AcceptChanges();
					c.SuppressEntityEvents = false;
				}
				rows.Add(c);
			}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="FreeLancer.HRB.Domains.Posts"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="FreeLancer.HRB.Domains.Posts"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, FreeLancer.HRB.Domains.Posts entity)
		{
			if (!reader.Read()) return;
			
			entity.PostId = (System.Guid)reader[((int)PostsColumn.PostId - 1)];
			entity.OriginalPostId = (System.Guid)reader["PostID"];
			entity.Title = (reader.IsDBNull(((int)PostsColumn.Title - 1)))?null:(System.String)reader[((int)PostsColumn.Title - 1)];
			entity.ImagePath = (reader.IsDBNull(((int)PostsColumn.ImagePath - 1)))?null:(System.String)reader[((int)PostsColumn.ImagePath - 1)];
			entity.Description = (reader.IsDBNull(((int)PostsColumn.Description - 1)))?null:(System.String)reader[((int)PostsColumn.Description - 1)];
			entity.PostContent = (reader.IsDBNull(((int)PostsColumn.PostContent - 1)))?null:(System.String)reader[((int)PostsColumn.PostContent - 1)];
			entity.DateCreated = (reader.IsDBNull(((int)PostsColumn.DateCreated - 1)))?null:(System.DateTime?)reader[((int)PostsColumn.DateCreated - 1)];
			entity.DateModified = (reader.IsDBNull(((int)PostsColumn.DateModified - 1)))?null:(System.DateTime?)reader[((int)PostsColumn.DateModified - 1)];
			entity.Author = (reader.IsDBNull(((int)PostsColumn.Author - 1)))?null:(System.String)reader[((int)PostsColumn.Author - 1)];
			entity.IsPublished = (System.Boolean)reader[((int)PostsColumn.IsPublished - 1)];
			entity.Slug = (reader.IsDBNull(((int)PostsColumn.Slug - 1)))?null:(System.String)reader[((int)PostsColumn.Slug - 1)];
			entity.Phone = (reader.IsDBNull(((int)PostsColumn.Phone - 1)))?null:(System.String)reader[((int)PostsColumn.Phone - 1)];
			entity.Email = (reader.IsDBNull(((int)PostsColumn.Email - 1)))?null:(System.String)reader[((int)PostsColumn.Email - 1)];
			entity.Address = (reader.IsDBNull(((int)PostsColumn.Address - 1)))?null:(System.String)reader[((int)PostsColumn.Address - 1)];
			entity.IsCommentAllowed = (reader.IsDBNull(((int)PostsColumn.IsCommentAllowed - 1)))?null:(System.Boolean?)reader[((int)PostsColumn.IsCommentAllowed - 1)];
			entity.AttachedPath = (reader.IsDBNull(((int)PostsColumn.AttachedPath - 1)))?null:(System.String)reader[((int)PostsColumn.AttachedPath - 1)];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="FreeLancer.HRB.Domains.Posts"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="FreeLancer.HRB.Domains.Posts"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, FreeLancer.HRB.Domains.Posts entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.PostId = (System.Guid)dataRow["PostID"];
			entity.OriginalPostId = (System.Guid)dataRow["PostID"];
			entity.Title = Convert.IsDBNull(dataRow["Title"]) ? null : (System.String)dataRow["Title"];
			entity.ImagePath = Convert.IsDBNull(dataRow["ImagePath"]) ? null : (System.String)dataRow["ImagePath"];
			entity.Description = Convert.IsDBNull(dataRow["Description"]) ? null : (System.String)dataRow["Description"];
			entity.PostContent = Convert.IsDBNull(dataRow["PostContent"]) ? null : (System.String)dataRow["PostContent"];
			entity.DateCreated = Convert.IsDBNull(dataRow["DateCreated"]) ? null : (System.DateTime?)dataRow["DateCreated"];
			entity.DateModified = Convert.IsDBNull(dataRow["DateModified"]) ? null : (System.DateTime?)dataRow["DateModified"];
			entity.Author = Convert.IsDBNull(dataRow["Author"]) ? null : (System.String)dataRow["Author"];
			entity.IsPublished = (System.Boolean)dataRow["IsPublished"];
			entity.Slug = Convert.IsDBNull(dataRow["Slug"]) ? null : (System.String)dataRow["Slug"];
			entity.Phone = Convert.IsDBNull(dataRow["Phone"]) ? null : (System.String)dataRow["Phone"];
			entity.Email = Convert.IsDBNull(dataRow["Email"]) ? null : (System.String)dataRow["Email"];
			entity.Address = Convert.IsDBNull(dataRow["Address"]) ? null : (System.String)dataRow["Address"];
			entity.IsCommentAllowed = Convert.IsDBNull(dataRow["IsCommentAllowed"]) ? null : (System.Boolean?)dataRow["IsCommentAllowed"];
			entity.AttachedPath = Convert.IsDBNull(dataRow["AttachedPath"]) ? null : (System.String)dataRow["AttachedPath"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="FreeLancer.HRB.Domains.Posts"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">FreeLancer.HRB.Domains.Posts Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		public override void DeepLoad(TransactionManager transactionManager, FreeLancer.HRB.Domains.Posts entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			// Deep load child collections  - Call GetByPostId methods when available
			
			#region PostCommentCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<PostComment>|PostCommentCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'PostCommentCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.PostCommentCollection = DataRepository.PostCommentProvider.GetByPostId(transactionManager, entity.PostId);

				if (deep && entity.PostCommentCollection.Count > 0)
				{
					deepHandles.Add("PostCommentCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<PostComment>) DataRepository.PostCommentProvider.DeepLoad,
						new object[] { transactionManager, entity.PostCommentCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region PostCategoryCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<PostCategory>|PostCategoryCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'PostCategoryCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.PostCategoryCollection = DataRepository.PostCategoryProvider.GetByPostId(transactionManager, entity.PostId);

				if (deep && entity.PostCategoryCollection.Count > 0)
				{
					deepHandles.Add("PostCategoryCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<PostCategory>) DataRepository.PostCategoryProvider.DeepLoad,
						new object[] { transactionManager, entity.PostCategoryCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the FreeLancer.HRB.Domains.Posts object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">FreeLancer.HRB.Domains.Posts instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">FreeLancer.HRB.Domains.Posts Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		public override bool DeepSave(TransactionManager transactionManager, FreeLancer.HRB.Domains.Posts entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
	
			#region List<PostComment>
				if (CanDeepSave(entity.PostCommentCollection, "List<PostComment>|PostCommentCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(PostComment child in entity.PostCommentCollection)
					{
						if(child.PostIdSource != null)
						{
							child.PostId = child.PostIdSource.PostId;
						}
						else
						{
							child.PostId = entity.PostId;
						}

					}

					if (entity.PostCommentCollection.Count > 0 || entity.PostCommentCollection.DeletedItems.Count > 0)
					{
						//DataRepository.PostCommentProvider.Save(transactionManager, entity.PostCommentCollection);
						
						deepHandles.Add("PostCommentCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< PostComment >) DataRepository.PostCommentProvider.DeepSave,
							new object[] { transactionManager, entity.PostCommentCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<PostCategory>
				if (CanDeepSave(entity.PostCategoryCollection, "List<PostCategory>|PostCategoryCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(PostCategory child in entity.PostCategoryCollection)
					{
						if(child.PostIdSource != null)
						{
							child.PostId = child.PostIdSource.PostId;
						}
						else
						{
							child.PostId = entity.PostId;
						}

					}

					if (entity.PostCategoryCollection.Count > 0 || entity.PostCategoryCollection.DeletedItems.Count > 0)
					{
						//DataRepository.PostCategoryProvider.Save(transactionManager, entity.PostCategoryCollection);
						
						deepHandles.Add("PostCategoryCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< PostCategory >) DataRepository.PostCategoryProvider.DeepSave,
							new object[] { transactionManager, entity.PostCategoryCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region PostsChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>FreeLancer.HRB.Domains.Posts</c>
	///</summary>
	public enum PostsChildEntityTypes
	{

		///<summary>
		/// Collection of <c>Posts</c> as OneToMany for PostCommentCollection
		///</summary>
		[ChildEntityType(typeof(TList<PostComment>))]
		PostCommentCollection,

		///<summary>
		/// Collection of <c>Posts</c> as OneToMany for PostCategoryCollection
		///</summary>
		[ChildEntityType(typeof(TList<PostCategory>))]
		PostCategoryCollection,
	}
	
	#endregion PostsChildEntityTypes
	
	#region PostsFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;PostsColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Posts"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class PostsFilterBuilder : SqlFilterBuilder<PostsColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PostsFilterBuilder class.
		/// </summary>
		public PostsFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the PostsFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public PostsFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the PostsFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public PostsFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion PostsFilterBuilder
	
	#region PostsParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;PostsColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Posts"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class PostsParameterBuilder : ParameterizedSqlFilterBuilder<PostsColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PostsParameterBuilder class.
		/// </summary>
		public PostsParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the PostsParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public PostsParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the PostsParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public PostsParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion PostsParameterBuilder
	
	#region PostsSortBuilder
    
    /// <summary>
    /// A strongly-typed instance of the <see cref="SqlSortBuilder&lt;PostsColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Posts"/> object.
    /// </summary>
    [CLSCompliant(true)]
    public class PostsSortBuilder : SqlSortBuilder<PostsColumn>
    {
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PostsSqlSortBuilder class.
		/// </summary>
		public PostsSortBuilder() : base() { }

		#endregion Constructors

    }    
    #endregion PostsSortBuilder
	
} // end namespace
